﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Xcj.Mes.WholeLine.DataBase.Common;

namespace Xcj.Mes.WholeLine.DataBase.Entity
{
    public class PlcAddressEntity : BaseEntity
    {
        // 钉卷 组立 老化 座板 其它
        private string _deviceType = string.Empty;
        [Alias("设备类型"), StringLength(32)]
        public string DeviceType
        {
            get => _deviceType;
            set
            {
                _deviceType = value?.Trim();
                RaisePropertyChanged();
            }
        }

        private string _name = string.Empty;
        [Alias("数据名称"), StringLength(32)]
        [Column("Name")]
        public string Name { get => _name; set { _name = value?.Trim(); RaisePropertyChanged(); } }

        private string _address = string.Empty;
        [Alias("数据地址"), StringLength(32)]
        [Column("Address")]
        public string Address { get => _address; set { _address = value?.Trim(); RaisePropertyChanged(); } }

        private string _addressClass = string.Empty;
        [Alias("数据分类"), StringLength(32)]
        [Column("AddressClass")]
        public string AddressClass { get => _addressClass; set { _addressClass = value?.Trim(); RaisePropertyChanged(); } }

        private string _dataType = string.Empty;
        [Alias("数据类型"), StringLength(16)]
        [Column("DataType")]
        public string DataType { get => _dataType; set { _dataType = value?.Trim(); RaisePropertyChanged(); } }

        private int _dataLength = 0;
        [Alias("数据长度")]
        [Column("DataLength")]
        public int DataLength { get => _dataLength; set { _dataLength = value; RaisePropertyChanged(); } }
        
        private int _bit = 0;
        [Alias("Bit位")]
        [Column("Bit")]
        public int Bit { get => _bit; set { _bit = value; RaisePropertyChanged(); } }

        private string _value = string.Empty;
        [Alias("数值"), StringLength(64)]
        [Column("Value")]
        public string Value { get => _value; set { _value = value?.Trim(); RaisePropertyChanged(); } }

        private string _mode = string.Empty;
        [Alias("读写模式"), StringLength(16)]
        [Column("Mode")]
        public string Mode { get => _mode; set { _mode = value?.Trim(); RaisePropertyChanged(); } }

        private bool _hasPeriod = false;
        [Alias("是否周期性读写")]
        [Column("HasPeriod")]
        public bool HasPeriod { get => _hasPeriod; set { _hasPeriod = value; RaisePropertyChanged(); } }

        private int _period = 500;
        [Alias("持续读写周期")]
        [Column("Period")]
        public int Period { get => _period; set { _period = value; RaisePropertyChanged(); } }
    }
}
